﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <Python.h>
#include <QMainWindow>
#include <QSignalMapper>
#include <QButtonGroup>
#include <QMdiSubWindow>
#include <QMenu>
#include <QtAdvancedStylesheet.h>
#include <QmlStyleUrlInterceptor.h>
#include <QGraphicsOpacityEffect>
#include <qtimer.h>
#include <QPalette>
#include <QSystemTrayIcon>

#include "otherwidgets/downloadlistwidget.h"
#include "otherwidgets/singledownloadframe.h"
#include "otherwidgets/about/aboutsoftwaredialog.h"
#include "otherwidgets/help/helpwidget.h"
#include "subwindow/submdwindow.h"
#include "global/mainglobalvar.h"
#include "QHotkey/qhotkey.h"
#include "universal/file/userssettings.h"
#include "universal/script/image/snapShoot.h"
#include "struct/editor/EditorConfig.h"
#include "customize/customizedTrayMenu/traymenu.h"


namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    void saveSettings();
    void loadSettings();
    void hideSomeItems();
    void loadThemes();
    void readCustomizedThemeFile();
    void onCustomizedThemesTriggered();
    void updateTheme();
    void loadDefaultSettings();
    void getRandomSentence();
    void copySentence();
    void changeToWorkingUI();
    void showStateInfo(QString state);
    void checkSubWindows(QMdiSubWindow *window);
    void createMusicSubWindow();
    void createVideoSubWindow();
    void createTextTransitionSubWindow();
    void createRandomLearningSubWindow();
    void createSSJJSubWindow();
    void createAASubWindow();
    void createFilesConvertSubWindow();
    // 创建MD编辑器子窗口
    void createMDSubWindow();
    void createHardwareDevelopmentSubWindow();
    void addDownloadTask(SingleDownloadFrame *singleDownloadFrame);
    // 切换语言
    void changeLanguage(QString language);
    void buildUIPanel();
    // 创建托盘菜单
    void setupTrayIconMenu(QSystemTrayIcon* trayIcon);

private:
    Ui::MainWindow *ui;
    QString appDir;
    QString currentTheme;                       // 当前主题
    int currentThemeType;
    QSignalMapper *signalMapper;
    QButtonGroup *taskButtonList;
    QWidgetList *subWindowList;
    DownloadListWidget *downloadListWidget;
    acss::QtAdvancedStylesheet* advancedStyleSheet;
    EditorConfig editorConfig;
    // 系统托盘图标
    QSystemTrayIcon* trayIcon;
    TrayMenu *trayMenu;

    void showHelpWidget();

protected:
    void closeEvent(QCloseEvent* event) override;

private slots:
    void onThemeActionTriggered();
    void onStyleManagerStylesheetChanged();
    // 改变窗口大小
    void receiveDsizeInfo(int dwidth, int dheight);
    void testPythonCode();
    void developeModeChanged();
    void changeWindowTitle();
    void showAboutSoftWareDialog();
    void exportFilesIntoApplicationDir();
    void quitApp();
    // 托盘图标点击
    void onTrayIconClicked(QSystemTrayIcon::ActivationReason reason);

public: signals:
    void isAnyChildWindow();
    void updateQuickWidgetTheme(acss::QtAdvancedStylesheet* advancedStyleSheet);
    void getGlobalEditorConfig(EditorConfig globalEditorConfig);
    // 切换语言
    void languageChanged(QString language);
    // 截屏信号
    void snapScreen();
};
#endif // MAINWINDOW_H
